package com.hzit.aop.service.impl;

import com.hzit.aop.dao.UserDao;
import com.hzit.aop.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserServiceImpl implements UserService {
	@Autowired
	private UserDao userDao;

	// 注解式事务处理
	@Transactional
	@Override
	public void trans(int uid1, int uid2, int money) {
		//1. 转出
		userDao.update(uid1,money);
		// int i = 10 / 0;
		//2. 转入
		userDao.update(uid2,-money);
	}
}
